
# -e : Exit immediately if a command exits with a non-zero status.
# -o pipefail : The return value of a pipeline is the status of the last command
set -eo pipefail

function source_or_warn() {
    if [[ -e $1 ]]; then
        . "$1" || echo "source failed: $1"
    else
        echo "source not found: $1"
    fi
}

function source_or_skip() {
    if [[ -e $1 ]]; then
        . "$1" || echo "source failed: $1"
    fi
}

alias safe_source=source_or_warn

# source "$HOME/.config/shell/env.sh" and gen $PATH inside
source_or_warn "$DOTMY/profiles/base/env.sh"

# if [[ -s $PATH_next ]]; then
#     PATH_OLD_1="$PATH"
#     export PATH="${PATH_next}"
# fi

set +e
set +o pipefail

true
